using StructureMap;
using BattleThis.Core;
using System.Runtime.CompilerServices;
using System;

namespace BattleThis {
    public static class IoC 
	{
        public static IContainer Initialize() 
		{

            ObjectFactory.Initialize(x =>
                        {
                            x.Scan(scan =>
                                    {   scan.TheCallingAssembly();
                                        scan.WithDefaultConventions();
                                    });

							x.For( typeof( IUnitOfWorkFactory ) ).Use( typeof( RavenDB.RavenUnitOfWorkFactory ) );
							x.For( typeof( IUnitOfWork ) ).Use( context => { return PersistenceContext.Current.UnitOfWork; } );
							x.For( typeof (IRepository<>)).Use(typeof (RavenDB.RavenRepository<>));
							
                        });

            return ObjectFactory.Container;
        }
    }
}